﻿$(document).ready(function () {
    $("#username").focus();
})
function onEnterDown() {
    if (window.event.keyCode == 13) {
        submit_login();
    }
}
function submit_login() {
    var admin_uname = $("#username").val();
    var admin_psw = $("#password").val();
    if (admin_uname == "") {
        alert("请输入账号！");
        $("#username").focus();
        return false
    }
    if (admin_psw == "") {
        alert("请输入密码！");
        $("#password").focus();
        return false
    }
    $.ajax({
        type: "get",
        url: "../../Service/BasicDataManageHandler.ashx?action=UserLogin&paramName=" + escape(admin_uname) + "&paramPwd=" + admin_psw,
        eache: false,
        success: function (reg) {
            var arr = reg.split('|');
            var returnval = arr[0];
            var tip = arr[1];
            if (returnval == "3") {
                alert(tip);
                $("#username").val("");
                $("#password").val("");
                $("#username").focus();
                return false;
            }
            else if (returnval == "8") {
                alert(tip);
                $("#username").val("");
                $("#password").val("");
                $("#username").focus();
                return false;
            }
            else if (returnval == "9") {
                alert(tip);
                $("#password").val("");
                $("#password").focus();
                return false;
            }
            else if (returnval == "14") {
                alert(tip);
                $("#username").val("");
                $("#password").val("");
                $("#username").focus();
                return false;
            }
            else if (returnval == "20" || returnval == "30") {
                alert(tip);
                $("#username").focus();
                return false;
            }
            else if (returnval == "10") {
                window.location.href = "index.aspx";
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
            $("#username").val("");
            $("#password").val("");
            $("#username").focus();
        }
    });
}


function forgetPwd() {
    window.showModalDialog('CommForm/ForgetPwdForm.aspx', window, 'dialogWidth=300px;dialogHeight=198px;status=no');
}